package com.tdkj.action.backstage.shop;

import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import com.tdkj.action.BaseAction;
import com.tdkj.model.shop.BeanEvaluateType;
import com.tdkj.service.shop.IBeanEvaluateTypeService;


public class ShelfAction extends BaseAction {
    
	private IBeanEvaluateTypeService evaluateTypeService;
	
	
	private Long id;
	private String name;
	private Integer score;
	private Integer ordinal;
	
	private BeanEvaluateType evaluateType ;
	
	private List<BeanEvaluateType> evaluateTypes ;
	
	private List<Long> ids ;
	private List<Integer> scores ;
	
	public String add() {
		evaluateTypeService.addEvaluateType(name, score);
		return execute();
	}
	
	public String update() {
		if(ids!=null && scores!=null && ids.size()!=0 && ids.size()==scores.size()){
			evaluateTypeService.updateEvaluateType(ids, scores);
		}
		return execute();
	}

	public String del() {
		evaluateTypeService.delete(id, BeanEvaluateType.class);
		return execute();
	}
	
	public String execute() {
		LinkedHashMap<String,String> orderInfos = new LinkedHashMap<String,String>();
		orderInfos.put("ordinal", "asc");
		evaluateTypes = evaluateTypeService.findAll(BeanEvaluateType.class, orderInfos);
		return "success";
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the score
	 */
	public Integer getScore() {
		return score;
	}

	/**
	 * @param score the score to set
	 */
	public void setScore(Integer score) {
		this.score = score;
	}

	/**
	 * @return the ordinal
	 */
	public Integer getOrdinal() {
		return ordinal;
	}

	/**
	 * @param ordinal the ordinal to set
	 */
	public void setOrdinal(Integer ordinal) {
		this.ordinal = ordinal;
	}

	/**
	 * @return the evaluateType
	 */
	public BeanEvaluateType getEvaluateType() {
		return evaluateType;
	}

	/**
	 * @param evaluateType the evaluateType to set
	 */
	public void setEvaluateType(BeanEvaluateType evaluateType) {
		this.evaluateType = evaluateType;
	}

	/**
	 * @return the evaluateTypes
	 */
	public List<BeanEvaluateType> getEvaluateTypes() {
		return evaluateTypes;
	}

	/**
	 * @param evaluateTypes the evaluateTypes to set
	 */
	public void setEvaluateTypes(List<BeanEvaluateType> evaluateTypes) {
		this.evaluateTypes = evaluateTypes;
	}

	/**
	 * @param evaluateTypeService the evaluateTypeService to set
	 */
	@Resource
	public void setEvaluateTypeService(IBeanEvaluateTypeService evaluateTypeService) {
		this.evaluateTypeService = evaluateTypeService;
	}

	/**
	 * @return the ids
	 */
	public List<Long> getIds() {
		return ids;
	}

	/**
	 * @param ids the ids to set
	 */
	public void setIds(List<Long> ids) {
		this.ids = ids;
	}

	/**
	 * @return the scores
	 */
	public List<Integer> getScores() {
		return scores;
	}

	/**
	 * @param scores the scores to set
	 */
	public void setScores(List<Integer> scores) {
		this.scores = scores;
	}

	

}
